package net.root.plain.alarm;

import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;

public class TimeUtil {
	public static String convertString(long time){
		SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
		return sdf.format(new Timestamp(time));
	}
	
	public static long convertTimestamp(String time){
		long result=0L;
		Calendar cal;
		time = "2000:01:01:"+time+":00";
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy:MM:dd:HH:mm:ss");
		System.out.println("debug"+time);
		try {
			sdf.parse(time);
			cal = sdf.getCalendar();
			Timestamp ts = new Timestamp(cal.getTime().getTime());
			result = ts.getTime();
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return result;
	}
}
